package pyf.demo09;

/**
 * @author pengyifeng
 * @version 5.1
 * @ClassName ThreadPriorityDemo.java
 * @Description 线程优先等级设置
 * @createTime 2021年07月27日 10:18:00
 */
public class ThreadPriorityDemo {
    public static void main(String[] args) {
        //主线程优先等级
        System.out.println(Thread.currentThread().getName() + "==>" + Thread.currentThread().getPriority());

        MyThreadPriority myThreadPriority=new MyThreadPriority();
        Thread thread = new Thread(myThreadPriority,"线程a");
        thread.setPriority(Thread.MIN_PRIORITY);
        thread.start();
        Thread thread1 = new Thread(myThreadPriority,"线程b");
        thread1.setPriority(Thread.NORM_PRIORITY);
        thread1.start();
        Thread thread2 = new Thread(myThreadPriority,"线程c");
        thread2.setPriority(Thread.MAX_PRIORITY);
        thread2.start();

    }
static class MyThreadPriority implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"我的线程");
    }
}
}
